# 下载好之后格式不对, 整理一下格式.
# 章节名不需要 \t, 
# 且每章前加一个 ------------

import re

with open('大时代1994_柳岸花又明.txt', 'r', encoding='utf-8') as file, open('大时代1994_柳岸花又明_formated.txt', 'w', encoding='utf-8') as outfile:
    text = '\n\n'
    pattern = r'^\d+、(.+)'
    n = 0
    for line in file:
        if re.match(pattern, line):
            n += 1
            line = re.sub(pattern, rf'第{n}章 \1', line)
            line = text + line
            # print(line)
            # if line[0] == '1':
            #     pass
            # else:
            #     line = text + line
            
            # print(line)

            # if n > 10:
            #     break
        else:
            line = line
        
        outfile.write(line)
    


